cmake_minimum_required(VERSION 3.13)

set(CMAKE_CXX_STANDARD 20)

project(datetime VERSION 0.0.1 LANGUAGES CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
# 设置输出目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")

include(fmt)

add_library(datetime STATIC ${PROJECT_SOURCE_DIR}/src/datetime.cc)
target_include_directories(datetime PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(datetime PRIVATE fmt)

add_library(datetime::datetime ALIAS datetime)

option(BUILD_DATETIME_TESTS "Build the datetime tests" ON)
if(BUILD_DATETIME_TESTS)
    add_subdirectory(test)
endif()
